package org.hncors.gnssparse.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import org.hncors.gnssparse.R;
import org.hncors.gnssparse.SettingPageGnssInfoSatelliteListActivity;
import org.hncors.gnssparse.model.SatelliteItemData;

import java.util.ArrayList;

/**
 * Created by Yagui Cheng(240654418@qq.com) on 2018/8/6.
 */

public class SatelliteItemAdapter extends BaseAdapter {
        private Context mContext;
        private LayoutInflater mLayoutInflater;
    private ArrayList<SatelliteItemData> mSateItemsDataArray;
        public SatelliteItemAdapter(Context context, ArrayList<SatelliteItemData> mList) {
            mContext = context;
            mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mSateItemsDataArray = mList;
        }

        @Override
        public int getCount() {
            return mSateItemsDataArray.size();
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null)
                convertView = mLayoutInflater.inflate(R.layout.layout_setting_gnss_info_satellite_list_item, null);


            TextView satelliteNum = (TextView) convertView.findViewById(R.id.TextViewSateNum);
            if (satelliteNum != null)
                satelliteNum.setText(mSateItemsDataArray.get(position).mSatelliteNum);

            //SNRL
            TextView satelliteSnrl = (TextView) convertView.findViewById(R.id.textViewSnrl);
            if (satelliteSnrl != null)
                satelliteSnrl.setText(mSateItemsDataArray.get(position).mSatelliteSnrl);


            TextView satelliteElevationAngle = (TextView) convertView.findViewById(R.id.textViewElevatingAngle);
            if (satelliteElevationAngle != null)
                satelliteElevationAngle.setText(mSateItemsDataArray.get(position).mSatelliteElevatingAngle);


            TextView satelliteAzimuthalAngle = (TextView) convertView.findViewById(R.id.textViewAzimuthalAngle);
            if (satelliteAzimuthalAngle != null)
                satelliteAzimuthalAngle.setText(mSateItemsDataArray.get(position).mSatelliteAzimuthalAngle);


            TextView satelliteStatue = (TextView) convertView.findViewById(R.id.textViewStatus);
            if (satelliteStatue != null)
                satelliteStatue.setText(mSateItemsDataArray.get(position).mSatelliteStatus);

            return convertView;
        }
}
